//
//  QueryOperator.m
//  CJRailTransport
//
//  Created by Hank on 2017/11/28.
//  Copyright © 2017年 amplity. All rights reserved.
//

#import "QueryOperator.h"
#define kAPISubPath @"cetmsplat"

@implementation QueryOperator

- (instancetype)init
{
    self = [super init];
    if (self) {
        [self setHostWithPath:kAPISubPath];
    }
    return self;
}

// 查询列表
- (void)postQueryList:(NSDictionary *)info tag:(id)tag successBlock:(succeedBlock)successBlock failureBlock:(failureBlock)failureBlock
{
    NSString *url = [self getUrlWithMethod:@"property/APPlist"];
    
    DataVisitor *visitor = [[DataVisitor alloc] init];
    [visitor executePOSTWithUrl:url Params:info tag:tag successBlock:^(id respondObject) {
        if (successBlock) {
            //返回 codes 解析
            NSNumber *responseCode = [respondObject objectForKey:@"retcode"];
            if (responseCode.intValue == 1) {
                successBlock(respondObject);
            }else{
                failureBlock(respondObject);
            }
        }
    } failureBlock:^(id respondObject) {
        failureBlock(respondObject);
    }];
}
// 查询集装箱详细信息
- (void)postQueryContainer:(NSDictionary *)info tag:(id)tag successBlock:(succeedBlock)successBlock failureBlock:(failureBlock)failureBlock
{
    NSString *url = [self getUrlWithMethod:@"property/getConByVin"];
    
    DataVisitor *visitor = [[DataVisitor alloc] init];
    [visitor executePOSTWithUrl:url Params:info tag:tag successBlock:^(id respondObject) {
        if (successBlock) {
            //返回 codes 解析
            NSNumber *responseCode = [respondObject objectForKey:@"retcode"];
            if (responseCode.intValue == 1) {
                successBlock(respondObject);
            }else{
                failureBlock(respondObject);
            }
        }
    } failureBlock:^(id respondObject) {
        failureBlock(respondObject);
    }];
}
// 支架或托盘详情
- (void)postQueryStents:(NSDictionary *)info tag:(id)tag successBlock:(succeedBlock)successBlock failureBlock:(failureBlock)failureBlock
{
    NSString *url = [self getUrlWithMethod:@"property/getRackByVin"];
    
    DataVisitor *visitor = [[DataVisitor alloc] init];
    [visitor executePOSTWithUrl:url Params:info tag:tag successBlock:^(id respondObject) {
        if (successBlock) {
            //返回 codes 解析
            NSNumber *responseCode = [respondObject objectForKey:@"retcode"];
            if (responseCode.intValue == 1) {
                successBlock(respondObject);
            }else{
                failureBlock(respondObject);
            }
        }
    } failureBlock:^(id respondObject) {
        failureBlock(respondObject);
    }];
}
// 查询主从关系
- (void)postQueryOwnerMember:(NSDictionary *)info tag:(id)tag successBlock:(succeedBlock)successBlock failureBlock:(failureBlock)failureBlock
{
    NSString *url = [self getUrlWithMethod:@"property/getRelationShip"];
    
    DataVisitor *visitor = [[DataVisitor alloc] init];
    [visitor executePOSTWithUrl:url Params:info tag:tag successBlock:^(id respondObject) {
        if (successBlock) {
            //返回 codes 解析
            NSNumber *responseCode = [respondObject objectForKey:@"retcode"];
            if (responseCode.intValue == 1) {
                successBlock(respondObject);
            }else{
                failureBlock(respondObject);
            }
        }
    } failureBlock:^(id respondObject) {
        failureBlock(respondObject);
    }];
}

// 查询质损与维修
- (void)postQueryLossAndRepair:(NSDictionary *)info tag:(id)tag successBlock:(succeedBlock)successBlock failureBlock:(failureBlock)failureBlock
{
    NSString *url = [self getUrlWithMethod:@"property/getLossAndRepair"];
    
    DataVisitor *visitor = [[DataVisitor alloc] init];
    [visitor executePOSTWithUrl:url Params:info tag:tag successBlock:^(id respondObject) {
        if (successBlock) {
            //返回 codes 解析
            NSNumber *responseCode = [respondObject objectForKey:@"retcode"];
            if (responseCode.intValue == 1) {
                successBlock(respondObject);
            }else{
                failureBlock(respondObject);
            }
        }
    } failureBlock:^(id respondObject) {
        failureBlock(respondObject);
    }];
}

@end
